<template>
	<view class="container">
		<view class="list-cell b-b m-t" @click="navTo('./userInfo')" hover-class="cell-hover" :hover-stay-time="50">
			<text class="cell-tit">个人资料</text>
			<text class="cell-more iconfont icon-jiantouarrow487"></text>
		</view>
		<view class="list-cell b-b" @click="navTo('/pages/address/addressManage')" hover-class="cell-hover" :hover-stay-time="50">
			<text class="cell-tit">收货地址</text>
			<text class="cell-more iconfont icon-jiantouarrow487"></text>
		</view>
		<view class="list-cell" hover-class="cell-hover" :hover-stay-time="50">
			<text class="cell-tit">实名认证</text>
			<text class="cell-more iconfont icon-jiantouarrow487"></text>
		</view>
		<!-- #ifdef APP-PLUS -->
		<view class="list-cell m-t">
			<text class="cell-tit">消息推送</text>
			<switch :checked="isPushOn" color="#fa436a" @change="pushChange" />
		</view>
		<!-- #endif -->
		
		<view class="list-cell m-t b-b" @click="cleanStorage" hover-class="cell-hover" :hover-stay-time="50">
			<text class="cell-tit">清除缓存</text>
			<text class="cell-more iconfont icon-jiantouarrow487"></text>
		</view>
		<view class="list-cell b-b" @click="navTo('/pages/member/articleDetail?id=29&cid=24')" hover-class="cell-hover" :hover-stay-time="50">
			<text class="cell-tit">关于我们</text>
			<text class="cell-more iconfont icon-jiantouarrow487"></text>
		</view>
		<view class="list-cell">
			<text class="cell-tit">检查更新</text>
			<text class="cell-tip">当前版本 1.0.3</text>
			<text class="cell-more iconfont icon-jiantouarrow487"></text>
		</view>
		<view class="list-cell log-out-btn" @click="toLogout">
			<text class="cell-tit">退出登录</text>
		</view>

	</view>
</template>

<script>
	// #ifdef APP-PLUS
	import push from "@/common/push.js" //app推送信息
	// #endif
	export default {
		data() {
			return {
				userInfo:[],
				// #ifdef APP-PLUS
				isPushOn: false,
				// #endif
			};
		},
		onShow() {
			this.userInfo = uni.getStorageSync('gUserInfo');
			// 如果 this.userInfo为空，说明缓存里没有登陆信息，用户没有登陆，返回登陆页面
			if(this.userInfo.length<=0){
				uni.navigateTo({
					url:'./login'
				})
				return;
			}
			// #ifdef APP-PLUS
				this.updatePush();
			// #endif
		},
		methods:{
			navTo(url){
				uni.navigateTo({
					url:url
				})
			},
			//退出登录
			toLogout(){
				uni.showModal({
				    content: '确定要退出登录吗?',
				    success: (e)=>{
				    	if(e.confirm){
				    		uni.removeStorageSync("gUserInfo");
				    		setTimeout(()=>{
				    			uni.switchTab({
				    				url:'./member'
				    			})
				    		}, 200)
				    	}
				    }
				});
			},
			//清除缓存
			cleanStorage(){
				uni.showModal({
				    content: '确定要清理缓存吗?',
				    success: (e)=>{
				    	if(e.confirm){
				    		uni.clearStorageSync();
				    		setTimeout(()=>{
				    			uni.switchTab({
				    				url:'./member'
				    			})
				    		}, 200)
				    	}
				    }
				});
			},
			// #ifdef APP-PLUS
			//消息推送
			pushChange(e){
				this.isPushOn = e.detail.value;
				if(this.isPushOn){
					push.on();
				}else{
					push.off();
				}
			},
			updatePush(){
				this.isPushOn = push.isOn();
			}
			// #endif
		}
	}
</script>

<style lang='scss' scoped>
	page{
		
	}
	.container{
		padding:20rpx 20rpx 100rpx;
		background: $uni-bg-color-grey;
		box-sizing: box-sizing;
	}
	.list-cell{
		display:flex;
		align-items:baseline;
		line-height:60upx;
		padding:20rpx;
		position:relative;
		background: #fff;
		justify-content: center;
		margin-top: 4rpx;
		&.log-out-btn{
			margin-top: 80upx;
			.cell-tit{
				color: $uni-text-color;
				text-align: center;
				margin-right: 0;
			}
		}
		&.cell-hover{
			background:$uni-bg-color-grey;
		}
		&.b-b:after{
			left: 30upx;
		}
		&.m-t{
			margin-top: 16upx; 
		}
		.cell-more{
			align-self: baseline;
			font-size:$uni-font-size-lg;
			color:$uni-text-color-grey;
			margin-left:10upx;
		}
		.cell-tit{
			flex: 1;
			font-size:$uni-font-size-base + 2upx;
			color: $uni-text-color;
			margin-right:10upx;
		}
		.cell-tip{
			font-size: $uni-font-size-base;
			color:$uni-text-color;
		}
		switch{
			transform: translateX(16upx) scale(.84);
		}
		
	}
	/* 底部操作start */
	.footer-wapper{position:fixed;bottom:0;display: flex;flex-direction: column;width: 100%;}
	.footer-words{text-align: center;background-color: white;padding:20rpx;font-size: 32rpx;}
</style>
